home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / B-C / C++ FAQ Reference 1.0 / C++ FAQ Reference 1.0.rsrc / TEXT_1928.txt < prev    next >
Encoding:
Text File  |  1993-06-30  |  602 b   |  12 lines

  1. Static member variables must be given an explicit definition in exactly one module.  Ex:
  2.     class X {
  3.       //...
  4.       static int i;  //*declare* static member X::i
  5.       //...
  6.     };
  7. The linker will holler at you ('X::i is not defined') unless (exactly) one of your source files has something like the following:
  8.     int X::i = some_expression_evaluating_to_an_int;     //*define* X::i
  9. or:
  10.     int X::i;                     //define --but don't initialize-- X::i
  11.  
  12. The usual place to define static member variables of class 'X' is file 'X.C' (or X.cpp, X.cc, X.c++, X.c or X.cxx; see question on file naming conventions).